package com.dinghui.ebookbag.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.ut.device.UTDevice;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Jmh
 * on 2021-01-21
 * 共用工具类
 */
public class CommonUtils {

    //利用阿里UTD库 获取手机唯一标识（eg:https://www.jianshu.com/p/f421487e79c5）
    public static String getAliUtdid(Context context) {
        String utdid = UTDevice.getUtdid(context);
        utdid = utdid.replace("/", "");
        return utdid;
    }

    //获取版本名称
    public static String getAppVersionName(Context context) {
        PackageManager pm = context.getPackageManager();
        try {
            PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
            return pi.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}
